<!--
 * @Author: your name
 * @Date: 2021-06-29 17:31:16
 * @LastEditTime: 2021-06-30 18:20:33
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \mytest\vue指令测试.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.min.js"></script>
</head>
<body>
    <input type="text">
    <div id="app">
        <div>
            <input type="text" v-model="text" v-focus="'text'" charts-type="cansh">
        </div>
    </div>
</body>
</html>
<script>
    Vue.directive('focus', {
        // 当绑定元素插入到 DOM 中。
        inserted: function (el,binding,vnode) {
          console.log('元素',el)
          console.log('对象',binding)
          console.log('虚拟dom',vnode)
          // 聚焦元素
          el.focus();
        },
        bind: function(el,binding,vnode){
          console.log('元素',el)
          console.log('对象',binding)
          console.log('虚拟dom',vnode)
        },

        update: function (val, oldVal) {
            console.log('更新',val)
        }
    })

    new Vue({
        el: '#app',
        data: {
            text: '测试'
        },
        mounted () {
            
        }
    })
</script>